package com.wang.interview.tests.enums;

/**
 * @author: wang
 * @date: 2021/8/17 19:50
 * @description: 测试是不试懒加载
 */
public class T1 {
    public static void main(String[] args) {
        System.out.println(A.a);
        /**
         * aaa
         * aaa
         * a,说明在使用A.a时，才实例化了a，是懒加载
         */
    }
}

enum A{
    a("123"),b("456");

    private String name = test();

    A(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    private String test(){
        System.out.println("aaa");
        return "";
    }
}
